<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr " :key="item">
        <span>{{item}}</span>
        <button @click="btn1(index)">删除</button>
      </li>
    </ul>
    <button @click="btn">添加</button>
  </div>
</template>

<script>
export default {
data(){
  return {
    arr:[1,2,3,4,5]
  }
},
methods:{
  btn(){
    this.arr.push(parseInt(Math.random() * 10))
  },
  btn1(index){
    this.arr.splice(index, 1)
  }
}
}
</script>

<style>

</style>